﻿using System;
using System.IO;
namespace EHSubmit.Util
{
    /// <summary>
    /// 日志帮助类
    /// </summary>
    public class LogHelper
    {
        private LogHelper()
        {
        }

        private static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
        private static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");

        /// <summary>
        /// 初始化LOG4NET引擎
        /// </summary>
        public static void SetConfig()
        {
            log4net.Config.DOMConfigurator.Configure();
        }

        /// <summary>
        /// 记录信息
        /// </summary>
        /// <param name="info">信息</param>
        public static void Log(string info)
        {
            if (loginfo.IsInfoEnabled)
            {
                loginfo.Info(info);
            }
        }

        /// <summary>
        /// 记录异常
        /// </summary>
        /// <param name="info">信息</param>
        /// <param name="se">异常类</param>
        public static void Log(string info, Exception se)
        {
            if (logerror.IsErrorEnabled)
            {
                logerror.Error(info, se);
            }
        }
    }
}